package com.xy.novelweb.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

@Component
@Slf4j
public class JedisUtil {
		private static JedisPool jedisPool;

		@Autowired
		public void init(JedisPool jedisPool){
				JedisUtil.jedisPool = jedisPool;
		}

		public static Jedis getConnect(){
				Jedis jedis = jedisPool.getResource();
				jedis.auth("redis");
				return jedis;
		}
		public static void close (Jedis jedis) {
				if (jedis != null) {
						jedis.close();
				}
		}
}
